#coding=utf-8

from datetime import *
from dateutil.relativedelta import *

from stockdb.misc import *

results = []
a = date(2001,4,1)
end = date(2005, 8, 1)

da = relativedelta(months=+1)
da2 = relativedelta(days=+1)
while a < end:
    
    astr = a.isoformat()
    td = szzs.find_td(astr)
    
    if td:
        results.append( [astr, td.price.close] )
    else:
        b = a
        while True:
            b = b + da2
            td = szzs.find_td(b.isoformat())
            if td:
                results.append( [b.isoformat(), td.price.close] )
                break
                
    a = a + da
        
for i in results:
    print i[0], i[1]

#print len(results)
